<?php if ($sf_user->isAuthenticated()) {?>
<p id="logout"><a href="<?php echo  url_for('logout')?>">Logout</a></p>
<p id="connected">Connected as <?php
    $person = $sf_user->getAttribute('person');
    echo $person->getFirstName().' '.$person->getLastName()?>
    <br>
    <?php if ($person->hasAClub()) {
        echo 'Club: '.$person->getClub()->getName();
    } else {
        echo 'No club associated';
    }
    ?>
    <br>
    <?php
    echo 'Referee level: '.$person->getRefereeLevel();
    ?>
</p>

<?php } else {
    $form = new LoginForm();
    ?>
    <p id="loginTitle">Identifiez vous: </p>
    <form action="<?php echo url_for('checkLogin'); ?>" method="post" id="loginForm">
        <ul>
    <?php foreach ($form as $widget): ?>
        <?php if ($widget->hasError()): ?>
            <li class='error'><?php echo $widget->getError(); ?></li>
        <?php endif; ?>
        <?php if (!$widget->isHidden()) { ?>
            <li><span class="label"><?php echo $widget->renderLabel(); ?></span>
            <?php echo $widget->render() ?></li>
        <?php } else { ?>
            <li><?php echo $widget->render() ?></li>
        <?php } ?>
    <?php endforeach; ?>
        </ul>
        <p>
        <a href="<?php echo url_for('passLost'); ?>"><?php echo __('Password lost'); ?></a>
        <input type="submit" id='submit' value="<?php echo __('Log in'); ?>" />
        </p>
    </form>
    <p id="createLink"><a href="<?php echo url_for('register'); ?>"><?php echo __('Create your account'); ?></a></p>
<?php }?>

